<?php
namespace Database;

class Banner extends Base
{

    public function __construct()
    {
        $this->setModel(MODEL_BANNER);
    }

    public function getList($positionIn)
    {
        $now = getDateTime();
        $sql = $this->getSql();
        $sql->field('*');
        $sql->table($this->getTable());
        $sql->where('dry_position', 'in', $positionIn);
        $sql->andWhere('dry_start_time', '<=', $now['date_time']);
        $sql->andWhere('dry_end_time', '>=', $now['date_time']);
        $sql->andWhere('dry_status', '=', 1);
        $sql->setOrder('dry_sort', 'asc');
        $sql->setPage(1);
        $sql->setPageSize(100);
        $sql->setLimit();
        $list = $this->fetchAll($sql->get());
        $count = $this->fetchColumn($sql->getTotalSql());
        return [
            'list' => $list,
            'count' => $count
        ];
    }

}